package com.itheima.controller;

import com.itheima.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

//@Controller
//@ResponseBody
@RestController//代替上面的两个
@RequestMapping("/user")

public class UserController {
//    @RequestMapping( method = RequestMethod.POST)
    @PostMapping
    public String save(@RequestBody User user){
        System.out.println("user save"+user);
        return "{'module':'user save'}";
    }

//    @RequestMapping(value = "/{id}",method = RequestMethod.DELETE)
    @DeleteMapping("/{id}")
    public String delete(@PathVariable Integer id){//需要路径变量
        System.out.println("user delete"+id);
        return "{'module':'user delete'}";
    }

//    @RequestMapping(method = RequestMethod.PUT)
    @PutMapping
    public String update(@RequestBody User user){
        System.out.println("user update"+user);
        return "{'module':'user update'}";

    }
//    @RequestMapping(value = "/{id}",method = RequestMethod.GET)
    @GetMapping("/{id}")
    public String getById(@PathVariable int id){
        System.out.println("user getById"+id);
        return "'module':'use getById'";
    }
}
